# Contributor: Henrik Riomar <henrik.riomar@gmail.com>
# Maintainer: Drew DeVault <sir@cmpwn.com>
pkgname=swaylock
pkgver=1.5
pkgrel=4
pkgdesc="Screen locker for Wayland"
url="https://swaywm.org"
arch="all"
license="MIT"
options="!check" # no test suite
makedepends="cairo-dev
	gdk-pixbuf-dev
	libxkbcommon-dev
	linux-pam-dev
	meson
	ninja
	scdoc
	wayland-dev
	wayland-protocols
	"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/swaywm/swaylock/archive/$pkgver.tar.gz"

prepare() {
	default_prepare
	sed -i 's/login/base-auth/g' \
		pam/swaylock

	cat <<-__EOF__ >> pam/swaylock

	# Unlock GNOME Keyring if available
	-auth       optional     pam_gnome_keyring.so
	-session    optional     pam_gnome_keyring.so auto_start

	# Unlock KWallet if available
	-auth    optional        pam_kwallet.so
	-auth    optional        pam_kwallet5.so
	-session optional        pam_kwallet.so auto_start
	-session optional        pam_kwallet5.so auto_start
	__EOF__

}

build() {
	abuild-meson . output
	meson compile -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output

	mv "$pkgdir"/usr/share/fish/vendor_completions.d "$pkgdir"/usr/share/fish/completions
}

sha512sums="16dd9b912ca702849290cf18d91ffbd64a70118cc284982a84b567c4974fd4590b12707c0aae1fcda7ccd1caa7880f342c633b9345bd795c36702916696d1f67  swaylock-1.5.tar.gz"
